GraphLinksModel

StockSharp.Xaml.Diagram.GXDiagram.Model

The generic implementation of a diagram model consisting of nodes and subgraphs, with any number of explicit link data representing links between any two nodes.

Inherits: DiagramModel

Implements: ILinksModel, IDiagramModel, ISubGraphLinksModel, ISubGraphModel, IGroupsModel

Constructors

GraphLinksModel()

The default constructor produces an empty model.

Properties

GroupNodePath : string

Gets or sets a property path that that specifies how to get the key for "container" or group node data of a node data object.

LinkCategoryPath : string

Gets or sets a property path that that specifies how to find the category of a link data.

LinkFromParameterPath : string

Gets or sets a property path that that specifies how to get optional "port" parameter information for the "from" node data of a link data object.

LinkFromPath : string

Gets or sets a property path that that specifies how to get the key for the "from" node data of a link data object.

LinkLabelNodePath : string

Gets or sets a property path that that specifies how to get the key for the "label" node data of a link data object.

LinksSource : IEnumerable

Gets or sets the collection of link data items for the model.

LinkToParameterPath : string

Gets or sets a property path that that specifies how to get optional "port" parameter information for the "to" node data of a link data object.

LinkToPath : string

Gets or sets a property path that that specifies how to get the key for the "to" node data of a link data object.

MemberNodesPath : string

Gets or sets a property path that that specifies how to get a list of keys for the "member" nodes of a group node data object.

NodeCategoryPath : string

Gets or sets a property path that that specifies how to find the category of a node data.

NodeIsGroupPath : string

Gets or sets a property path that that specifies how to find out whether a node data is also a "container" group.

NodeIsLinkLabelPath : string

Gets or sets a property path that that specifies how to find out whether a node data is also a "label" for a link data.

NodeKeyIsNodeData : bool

Gets or sets whether all node data are also their own keys.

NodeKeyPath : string

Gets or sets a property path that that specifies how to get the key for node data.

NodeKeyReferenceAutoInserts : bool

Gets or sets whether a reference, when NodeKeyIsNodeData is true, automatically inserts the node into NodesSource.

NodesSource : IEnumerable

Gets or sets the collection of node data items for the model.

ValidCycle : ValidCycle

Specify what kinds of graphs this model allows.

Methods

AddCollectionCopy(GraphLinksModel{, GraphLinksModel{) : CopyDictionary<T, T, T, T>

Copy existing node and link data and add to this model.

coll
the collection of data to be copied
env
the ICopyDictionary used to keep track of copied objects; if null, the method will call CreateCopyDictionary, use it, and return it

Returns: the updated copy dictionary, mapping original data to copied data

AddLinkCopy(T) : T

Add a copy of a link data to this model.

linkdata

Returns: the copied link data

AddMemberNodeKey(T, T)

Add a "member" node data's key value to a node data's list of "members".

nodedata
the node data to be modified
memberkey
the key value of the new "member" node data
AddNode(T)

Add a node data to NodesSource.

nodedata
AddNodeCopy(T) : T

Add a copy of a node data to this model.

nodedata

Returns: the copied node data

AugmentCopyCollection(GraphLinksModel{)

Override this method to add more (related) data to be copied.

coll
the collection of data to be copied
AugmentCopyDictionary(GraphLinksModel{)

Override this method to avoid copying some data, or to change how copied references are resolved.

env
the dictionary mapping original objects to copied objects
ChangeDataValue(ModelChangedEventArgs, bool)

This is called during undo or redo to effect state changes to model data.

e
an edit describing the change to be performed
undo
true if undoing; false if redoing
ChangeModelValue(ModelChangedEventArgs, bool)

This is called during undo or redo to effect state changes to this model.

e
an edit describing the change to be performed
undo
true if undoing; false if redoing
CheckLinkValid(T, T, T, T, bool, T) : bool

This predicate is true if adding a link between two nodes/ports would result in a validly structured graph.

fromdata
a node key identifying the node data from which the link comes
fromparam
an optional value identifying which port on the "from" node the link is connected to
todata
a node key identify the node data to which the link goes
toparam
an optional value identifying which port on the "to" node the link is connected to
ignoreexistinglink
true if relinking; false if adding a new link
oldlinkdata
the original link data that might be modified, if is true

Returns: The behavior of this predicate depends on the value of ValidCycle and ValidUnconnectedLinks.

CheckMemberValid(T, T, bool) : bool

This predicate is true if adding a node to a group node would result in an invalid graph.

groupnodedata
the node data that is a group
membernodedata
a node data to be considered for adding to the group
ignoreexistingmembership
whether to ignore the 's existing group membership, because that member is being transferred out of its existing group

Returns: This returns false for membership that would break the tree structure of the model's graph of groups.

ClearUnresolvedReferences()

Forget all unresolved delayed or forward references.

CopyLink1(T, GraphLinksModel{) : T

This is the first pass of copying link data, responsible for constructing a copy and copying most of its properties.

linkdata
env
the dictionary mapping original objects to copied objects

Returns: the copied link data

CopyLink2(T, GraphLinksModel{, T, T, T, T)

This is the second pass of copying link data, responsible for fixing up references to other objects.

oldlinkdata
the original link data
env
the dictionary mapping original objects to copied objects
newlinkdata
the copied link data
newfromnodedata
for convenience, the copied "from" node
newtonodedata
for convenience, the copied "to" node
newlinklabel
for convenience, the copied "label" node
CopyNode1(T, GraphLinksModel{) : T

This is the first pass of copying node data, responsible for constructing a copy and copying most of its properties.

nodedata
env
the dictionary mapping original objects to copied objects

Returns: the copied node data

CopyNode2(T, GraphLinksModel{, T, T, IEnumerable<T>)

This is the second pass of copying node data, responsible for fixing up references to other objects.

oldnodedata
the original node data
env
the dictionary mapping original objects to copied objects
newnodedata
the copied node data
newgroup
for convenience, the copied "parent" node data
newmembers
for convenience, a list of newly copied member nodes
CreateCopyDictionary() : CopyDictionary<T, T, T, T>

Create an ICopyDictionary initialized for this model.

Returns: Normally this will be an empty dictionary.

CreateDataCollection() : DataCollection<T, T, T, T>

Create an empty IDataCollection for this model.

CreateInitializedCopy(GraphLinksModel{) : GraphLinksModel<T, T, T, T>

Make a copy of this model, without sharing the NodesSource or LinksSource collections.

init
This is a DataCollection that provides the initial node and link data. (Such data is not copied.) If this is null, the initial NodesSource and LinksSource values are empty collections.

Returns: a model just like this one, but with different data

DeleteMemberNodeKey(T, T)

This method actually implements the modification of a node data so that it's collection of children node data does not include a given .

nodedata
the node data to be modified; if null, this method does nothing
memberkey
the key value of the "member" node data; if null, this method does nothing
DeleteNode(T)

This method actually implements the removal of a node data from the NodesSource collection.

nodedata
DoGroupNodeChanged(T)

This should be called when a node data's membership in a group may have changed.

nodedata
the modified node data
DoLinkAdded(T)

This should be called when a link data object is added to the LinksSource collection.

linkdata
DoLinkCategoryChanged(T)

This should be called when a link data's category value may have changed.

linkdata
DoLinkLabelChanged(T)

This should be called when a link data's label node may have changed.

linkdata
DoLinkPortsChanged(T)

This should be called when a link data's connected node or port, either "from" or "to", may have changed.

linkdata
DoLinkRemoved(T)

This should be called when a link data object is removed from the LinksSource collection.

linkdata
DoMemberNodeKeyAdded(T, T)

This should be called when a "member" node data key has been added to the collection of "member" node keys.

nodedata
the modified node data
memberkey
the key for the added "member" node data
DoMemberNodeKeyRemoved(T, T)

This should be called when a "member" node data key has been removed from the collection of "member" node keys.

nodedata
the modified node data
memberkey
the key for the removed "member" node data
DoMemberNodeKeysChanged(T)

This should be called when a node data's list of "member" nodes has been replaced.

nodedata
DoNodeAdded(T)

This should be called when a node data object is added to the NodesSource collection.

nodedata
DoNodeCategoryChanged(T)

This should be called when a node data's category value may have changed.

nodedata
DoNodeKeyChanged(T)

This should be called when a node data's key value may have changed.

nodedata
DoNodeRemoved(T)

This should be called when a node data object is removed from the NodesSource collection.

nodedata
FindCategoryForNode(T) : string

Find the category of a node data.

nodedata

Returns: by default an empty string

FindGroupKeyForNode(T) : T

Find containing group node key for a given node data, if any.

nodedata

Returns: a for the containing group node, or the default value for that type if there is no container node for the node

FindIsGroupForNode(T) : bool

Find whether a node data is a group or container of other nodes.

nodedata
FindIsLinkLabelForNode(T) : bool

Find whether a node data is a "label" for a link data.

nodedata
FindKeyForNode(T) : T

Find the key for node data.

nodedata

Returns: the (hopefully) unique key for the given node data in this model

FindMemberNodeKeysForNode(T) : IEnumerable

Find the list of keys of the children nodes for a node data object.

nodedata

Returns: the list of child keys, an IEnumerable of

FindNodeByKey(T) : T

Given a key, find the node data with that key.

key
a value of null for this argument will result in the default value for

Returns: a ; the value will be the default for the type if no such node data is known to be in this model

GetCategoryForNode(T) : string

This method gets the category of a node.

nodedata

Returns: a String, defaulting to the empty string

GetConnectedNodesForNode(T, Predicate<T>) : IEnumerable<T>

Return a sequence of node data that are directly connected to a given node, in either direction.

nodedata
portpred
a predicate to be applied to each port parameter; if non-null, this predicate must be true for the node to be included in the return sequence

Returns: an IEnumerable

GetConnectedNodesForNode(T) : IEnumerable<T>

Return a sequence of node data that are directly connected to a given node, in either direction.

nodedata

Returns: an IEnumerable

GetFromLinksForNode(T) : IEnumerable<T>

Return a sequence of link data that are connnected at a given node data, only going into the given node.

nodedata

Returns: an IEnumerable

GetFromNodesForNode(T) : IEnumerable<T>

Return a sequence of node data that are directly connected by links going into a given node.

nodedata

Returns: an IEnumerable

GetFromNodesForNode(T, Predicate<T>) : IEnumerable<T>

Return a sequence of node data that are directly connected by links going into a given node.

nodedata
toportpred
a predicate to be applied to each "to" port parameter; if non-null, this predicate must be true for the "from" node to be included in the return sequence

Returns: an IEnumerable

GetGroupForNode(T) : T

Return the container group node data for a given node data, if there is one.

nodedata

Returns: a node data

GetHasLabeledLinkForNode(T) : bool

This predicate is true for a node data if it is associated with a link data as its "label".

nodedata
GetIsGroupForNode(T) : bool

This predicate is true if a given node data may be a group (i.e. a container) of other nodes.

nodedata
GetIsLinkLabelForNode(T) : bool

This predicate is true if the given node data may be used as a "label" for a link.

nodedata
GetLabeledLinkForNode(T) : T

Get the link data that refers to a given node data as its "label".

nodedata

Returns: a link data

GetLinksBetweenNodes(T, T, T, T) : IEnumerable<T>

Return a sequence of all link data that go from one node to another, possibly restricted to certain "ports".

fromdata
a node key identifying the node data from which the link comes
fromparam
an optional value identifying which port on the "from" node the link is connected to
todata
a node key identify the node data to which the link goes
toparam
an optional value identifying which port on the "to" node the link is connected to

Returns: an IEnumerable

GetLinksForNode(T) : IEnumerable<T>

Return a sequence of link data that are connnected at a given node data, in either direction.

nodedata

Returns: an IEnumerable

GetLinksForNode(T, Predicate<T>) : IEnumerable<T>

Return a sequence of link data that are connnected at a given node data, in either direction, that satisfy a given predicate.

nodedata
predicate
a delegate that takes a as an argument and returns a boolean

Returns: an IEnumerable

GetMemberLinksForGroup(T) : IEnumerable<T>

Return a sequence of link data that are contained by a given node data.

nodedata

Returns: an IEnumerable of member link data; an empty sequence if there are no member links

GetMemberNodesForGroup(T) : IEnumerable<T>

Return a sequence of node data that are immediate members of a given node data.

nodedata

Returns: an IEnumerable of member node data; an empty sequence if there are no members

GetNodeType() : Type

Return the .

Returns: a Type, not a node data object, nor a string

GetToLinksForNode(T) : IEnumerable<T>

Return a sequence of link data that are connnected at a given node data, only coming out of the given node.

nodedata

Returns: an IEnumerable

GetToNodesForNode(T, Predicate<T>) : IEnumerable<T>

Return a sequence of node data that are directly connected by links coming out from a given node.

nodedata
fromportpred
a predicate to be applied to each "from" port parameter; if non-null, this predicate must be true for the "to" node to be included in the return sequence

Returns: an IEnumerable

GetToNodesForNode(T) : IEnumerable<T>

Return a sequence of node data that are directly connected by links coming out from a given node.

nodedata

Returns: an IEnumerable

HandleLinkPropertyChanged(object, PropertyChangedEventArgs)

This is the INotifyPropertyChanged event handler for link data.

sender
e
preferably a ModelChangedEventArgs that describes what changed and how
HandleNodePropertyChanged(object, PropertyChangedEventArgs)

This is the INotifyPropertyChanged event handler for node data.

sender
e
preferably a ModelChangedEventArgs that describes what changed and how
InsertMemberNodeKey(T, T)

This method actually implements the modification of a node data so that it's collection of member node data includes a given .

nodedata
the node data to be modified; if null, this method does nothing
memberkey
the key value of the new "member" node data; if null, this method does nothing
InsertNode(T)

This method actually implements the addition of a node data to the NodesSource collection.

nodedata
IsEqualPortParameters(T, T) : bool

This predicate compares two values and returns true if they are "equal".

a
b

Returns: Normally this uses the default EqualityComparer for the type. But you may need to override this method if that kind of equality comparison is inappropriate for your port information.

IsLinkData(T) : bool

This predicate is true if the argument is a link data in this model.

linkdata
the object to be checked to see if it is a known link data in this model

Returns: true if the is in the LinksSource

IsLinked(T, T, T, T) : bool

This predicate is true if there is a link from one node data/port to another one.

fromdata
a node key identifying the node data from which the link comes
fromparam
an optional value identifying which port on the "from" node the link is connected to
todata
a node key identify the node data to which the link goes
toparam
an optional value identifying which port on the "to" node the link is connected to
IsLinkType(object) : bool

Return the .

Returns: a Type, not a link data object, nor a string

IsLinkValid(T, T, T, T) : bool

This predicate is true if adding a link between two nodes/ports would result in a valid graph.

fromdata
a node key identifying the node data from which the link comes
fromparam
an optional value identifying which port on the "from" node the link is connected to
todata
a node key identify the node data to which the link goes
toparam
an optional value identifying which port on the "to" node the link is connected to
IsMember(T, T) : bool

This predicate is true if the is a member of the container group.

groupnodedata
membernodedata
IsMemberValid(T, T, bool) : bool

This predicate is true if adding to a group node () would result in an invalid graph.

groupnodedata
the node data that is a group
membernodedata
a node data
ignoreexistingmembership
whether to ignore the 's existing group membership, because that member is being transferred out of its existing group
IsNodeData(T) : bool

This predicate is true if the argument is a node data in this model.

nodedata
the object to be checked to see if it is a known node data in this model

Returns: true if the is in the NodesSource

IsNodeType(object) : bool

This predicate is true when the argument is an instance of .

nodedata
the arbitrary object to be checked for compatibility to be a node data

Returns: true if the can be cast to the ; false otherwise

IsRelinkValid(T, T, T, T, T) : bool

This predicate is true if replacing a link between two nodes/ports would result in a valid graph.

fromdata
a node key identifying the node data from which the link comes
fromparam
an optional value identifying which port on the "from" node the link is connected to
todata
a node key identify the node data to which the link goes
toparam
an optional value identifying which port on the "to" node the link is connected to
oldlinkdata
the original link data that might be modified
Load``2(XContainer, XName, XName)

Given a Linq for XML XContainer holding node and link data, replace this model's NodesSource and LinksSource collections with collections of new node data and new link data.

root
the XContainer holding all of the data
nodename
the name of each XElement holding node data
linkname
the name of each XElement holding link data
Load``2(XContainer, Func<XElement, T>, Func<XElement, T>)

Given a Linq for XML XContainer holding node and link data, replace this model's NodesSource and LinksSource collections with collections of new node data and new link data.

root
the XContainer holding all of the data
nodedataallocator
a function that takes an XElement and returns either a newly constructed object of type or null if that XElement is to be ignored
linkdataallocator
a function that takes an XElement and returns either a newly constructed object of type or null if that XElement is to be ignored
MakeNodeKeyUnique(T) : bool

This method is called when a duplicate key has been found.

nodedata

Returns: true to accept the data as a node after having made the key unique in the model; false to ignore this data.

ModifyGroupNodeKey(T, T)

This method actually implements the modification of a node data so that its reference to a containing group node data (if any) is the given .

nodedata
the node data to be modified
groupkey
the key value of the "group" node data
ModifyLinkFromPort(T, T, T)

This method actually implements the modification of a link data to change the reference to the "from" node data and the link's "from" port information.

linkdata
the link data to be modified
nodekey
the new node data's
portparam
ModifyLinkLabelKey(T, T)

This method actually implements the modification of a link data to change the reference to the "label" node data.

linkdata
the link data to be modified
linklabelkey
the new label data's
ModifyLinkToPort(T, T, T)

This method actually implements the modification of a link data to change the reference to the "to" node data and the link's "to" port information.

linkdata
the link data to be modified
nodekey
the new node data's
portparam
ModifyMemberNodeKeys(T, IEnumerable)

This method actually implements the replacement of a group node data's collection of member node keys.

nodedata
the node data to be modified
membernodekeys
a sequence of "member" node data key values
RemoveMemberNodeKey(T, T)

Remove a child node data's key value from a group node data's list of "member" key values.

nodedata
the node data to be modified
memberkey
the key value of the "member" node data
RemoveNode(T)

Remove a node data from NodesSource.

nodedata
ResolveAllReferences()

Cause ResolveNodeKey( to be called on each known delayed or forward node reference.

ResolveNodeKey(T)

This is called repeatedly by ResolveAllReferences, once for each known delayed or forward node reference.

nodekey
Save``2(XName, XName, XName)

Generate a Linq for XML XElement holding all of the node and link data.

rootname
the name of the returned XElement
nodename
the name of each XElement holding node data
linkname
the name of each XElement holding link data

Returns: an XElement

SetGroupNodeKey(T, T)

Change a node data so that it refers to a different container group node data, by node key.

nodedata
the node data to be modified
groupkey
the key value of the new "group" node data
SetLinkFromPort(T, T, T)

Change a link data so that it refers to a different "from" node data and associated port information.

linkdata
the link data to be modified
nodekey
the new node data's
portparam
SetLinkLabelKey(T, T)

Change a link data so that it refers to a different "label" node data.

linkdata
the link data to be modified
linklabelkey
the new label data's
SetLinkToPort(T, T, T)

Change a link data so that it refers to a different "to" node data and associated port information.

linkdata
the link data to be modified
nodekey
the new node data's
portparam
SetMemberNodeKeys(T, IEnumerable)

Replace a node data's list of "member" key values.

nodedata
the node data to be modified
membernodekeys
a sequence of "member" node data key values